package com.xiong.miaosha.utils;


import org.apache.commons.codec.digest.DigestUtils;

/**
 * @author wardseptember
 * @create 2020-03-16 09:45
 */
public class MD5Util {

     public static String MD5(String src) {
         return DigestUtils.md5Hex(src);
     }

     private static final String salt = "1a2b3c4d";

     public static String inputPassFromPass(String inputString) {
         String str = "" + salt.charAt(0) + salt.charAt(2) + inputString + salt.charAt(5) + salt.charAt(4);
         return MD5(str);
     }

     public static String fromPassToDBPass(String fromPass, String salt) {
         String str = "" + salt.charAt(0) + salt.charAt(2) + fromPass + salt.charAt(5) + salt.charAt(4);
         return MD5(str);
     }

     public static String inputPassToDBPass(String  inputString, String salt) {
         String fromPass = inputPassFromPass(inputString);
         String dbPass = fromPassToDBPass(fromPass, salt);
         return dbPass;
     }

    public static void main(String[] args) {
        System.out.println(inputPassToDBPass("123456", "1a2b3c4d"));
    }
}
